
#include "delay.h"

// delay_1ms()     1000个时钟周期
void delay_1ms(void) //@11.0592MHz
{
	unsigned char i, j;

	_nop_();
	i = 2;
	j = 199;
	do {
		while (--j)
			;
	} while (--i);
}

// delay_1s()     1000000个时钟周期
void delay_1s(void)
{
	unsigned char i, j, k;

	_nop_();
	i = 8;
	j = 1;
	k = 243;
	do {
		do {
			while (--k)
				;
		} while (--j);
	} while (--i);
}

// delay_us(unsigned char n)      n倍8个时钟周期的整数倍
void delay_us(unsigned char n)
{
	unsigned char i;
	for (i = 0; i < n; i++) {
		;
	}
}

// delay_ms(unsigned char n)      n倍1ms个时钟周期的整数倍 	误差千分之8
void delay_ms(unsigned char n)
{
	unsigned char i;
	for (i = 0; i < n; i++) {
		delay_1ms();
	}
}

// delay_ss(unsigned char n)       n倍1s个时钟周期的整数倍 	误差百万分之8
void delay_ss(unsigned char n)
{
	unsigned char i;
	for (i = 0; i < n; i++) {
		delay_1s();
	}
}
//#endif
